Skip to content

Simplify and fix InformationWeight Transform with column groups#153

Open
ryandewolfe33 wants to merge 7 commits into
TutteInstitute:masterfrom
ryandewolfe33:master
Open

Simplify and fix InformationWeight Transform with column groups#153
ryandewolfe33 wants to merge 7 commits into
TutteInstitute:masterfrom
ryandewolfe33:master

Conversation

@ryandewolfe33

Copy link
Copy Markdown
Contributor

The initial PR #150 that added column groups to the information weight transform added a few more branching paths and had an error (silent, answers were wrong) when both column groups and targets were passed. This PR fixes that error and simplifies the code. I also consolidated the info weight tests into a single test with more parameters.

I have also changed the interface to remove the single_column_group_weight parameter to simplify and since I am not sure why it would be used. I hope this is okay because there was no release since the last PR

@ryandewolfe33
ryandewolfe33 requested a review from jc-healy July 20, 2026 14:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes incorrect behavior in InformationWeight when combining supervision (target) with column_groups, and simplifies the implementation by consolidating baseline computation and removing the single_column_group_weight interface path.

Changes:

  • Add group-aware baseline marginal computation used consistently for both supervised and unsupervised information weighting.
  • Update supervised weighting to support column-group-aware baselines in InformationWeightTransformer.fit.
  • Consolidate/parameterize information-weight transformer tests and remove coverage for single_column_group_weight.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
vectorizers/transformers/info_weight.py Refactors baseline probability computation, removes single_column_group_weight, and fixes grouped+supervised weighting flow.
vectorizers/tests/test_transformers.py Consolidates IW transformer tests into a single parametrized test covering more fit argument combinations.
Comments suppressed due to low confidence (1)

vectorizers/transformers/info_weight.py:90

  • supervised_column_kl can return NaN when baseline_probabilities contains zeros (common when a class has zero mass within a column group). The expression observed * np.log(observed / baseline_probabilities) produces 0 * log(0/0) => NaN, which then propagates into weights.
    observed += prior_strength * baseline_probabilities
    observed /= observed.sum()

    return np.sum(observed * np.log(observed / baseline_probabilities))

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vectorizers/transformers/info_weight.py
Comment thread vectorizers/transformers/info_weight.py Outdated
Comment thread vectorizers/transformers/info_weight.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants